#include "utils.h"

unsigned char crc8(unsigned char *pcBlock, unsigned int len)
{
  unsigned char crc = 0xFF;
  unsigned int i;

  while (len--)
  {
    crc ^= *pcBlock++;

    for (i = 0; i < 8; i++)
    crc = crc & 0x80 ? (crc << 1) ^ 0x31 : crc << 1;
  }

  return crc;
}
